package com.google.gwt.gfx.client.graphics;

import com.google.gwt.gfx.client.shared.Point;
import com.google.gwt.gfx.client.style.StrokeStyle;
import com.google.gwt.user.client.Element;

public abstract class Line extends SimpleGraphic {

	public static Line get() {
		return GraphicFactory.DEFAULT.createLine();
	}

	private Point fromRef;

	private StrokeStyle strokeRef;

	private Point toRef;

	protected Line(Element element) {
		super(element);

		fromRef = new Point() {

			@Override
			public int getLeft() {
				return getFromLeft();
			}

			@Override
			public int getTop() {
				return getFromTop();
			}

			@Override
			public void setLeft(int left) {
				setFromLeft(left);
			}

			@Override
			public void setTop(int top) {
				setFromTop(top);
			}

		};
		toRef = new Point() {

			@Override
			public int getLeft() {
				return getToLeft();
			}

			@Override
			public int getTop() {
				return getToTop();
			}

			@Override
			public void setLeft(int left) {
				setToLeft(left);
			}

			@Override
			public void setTop(int top) {
				setToTop(top);
			}

		};
		strokeRef = GraphicFactory.DEFAULT.createStrokeOf(this);
	}

	public Point from() {
		return fromRef;
	}

	protected abstract int getFromLeft();

	protected abstract int getFromTop();

	protected abstract int getToLeft();

	protected abstract int getToTop();

	protected abstract void setFromLeft(int left);

	protected abstract void setFromTop(int top);

	protected abstract void setToLeft(int left);

	protected abstract void setToTop(int top);

	public StrokeStyle stroke() {
		return strokeRef;
	}

	public Point to() {
		return toRef;
	}

}
